﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package mochicrypt.as3 {
    import flash.events.*;
    import flash.display.*;
    import flash.utils.*;
    import flash.net.*;
    import flash.system.*;

    public class MochiAd {

        public static function getVersion():String{
            return (MochiServices.getVersion());
        }
        public static function showClickAwayAd(_arg1:Object):void{
            var clip:* = null;
            var mc:* = null;
            var chk:* = null;
            var options:* = _arg1;
            var DEFAULTS:* = {
                ad_timeout:2000,
                regpt:"o",
                method:"showClickAwayAd",
                res:"300x250",
                no_bg:true,
                ad_started:function ():void{
                },
                ad_finished:function ():void{
                },
                ad_loaded:function (_arg1:Number, _arg2:Number):void{
                },
                ad_failed:function ():void{
                    trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
                },
                ad_skipped:function ():void{
                }
            };
            options = MochiAd._parseOptions(options, DEFAULTS);
            clip = options.clip;
            var ad_timeout:* = options.ad_timeout;
            delete options.ad_timeout;
            if (!MochiAd.load(options)){
                options.ad_failed();
                options.ad_finished();
                return;
            };
            options.ad_started();
            mc = clip._mochiad;
            mc["onUnload"] = function ():void{
                MochiAd._cleanup(mc);
                options.ad_finished();
            };
            var wh:* = MochiAd._getRes(options, clip);
            var w:* = wh[0];
            var h:* = wh[1];
            mc.x = (w * 0.5);
            mc.y = (h * 0.5);
            chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
            chk.ad_timeout = ad_timeout;
            chk.started = getTimer();
            chk.showing = false;
            mc.unloadAd = function ():void{
                MochiAd.unload(clip);
            };
            mc.adLoaded = options.ad_loaded;
            mc.adSkipped = options.ad_skipped;
            mc.rpc = function (_arg1:Number, _arg2:Object):void{
                MochiAd.rpc(clip, _arg1, _arg2);
            };
            var sendHostProgress:* = false;
            mc.regContLC = function (_arg1:String):void{
                mc._containerLCName = _arg1;
            };
            chk["onEnterFrame"] = function ():void{
                var _local4:Number;
                if (!this.parent){
                    delete this.onEnterFrame;
                    return;
                };
                var _local1:Object = this.parent._mochiad_ctr;
                var _local2:Number = (getTimer() - this.started);
                var _local3:Boolean;
                if (!chk.showing){
                    _local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
                    if (_local4 > 0){
                        chk.showing = true;
                        _local3 = true;
                        chk.started = getTimer();
                    } else {
                        if (_local2 > chk.ad_timeout){
                            options.ad_failed();
                            _local3 = true;
                        };
                    };
                };
                if (this.root == null){
                    _local3 = true;
                };
                if (_local3){
                    delete this.onEnterFrame;
                };
            };
            doOnEnterFrame(chk);
        }
        public static function _isNetworkAvailable():Boolean{
            return (!((Security.sandboxType == "localWithFile")));
        }
        public static function _allowDomains(_arg1:String):String{
            var _local2:String = _arg1.split("/")[2].split(":")[0];
            if (Security.sandboxType == "application"){
                return (_local2);
            };
            Security.allowDomain("*");
            Security.allowDomain(_local2);
            Security.allowInsecureDomain("*");
            Security.allowInsecureDomain(_local2);
            return (_local2);
        }
        public static function unload(_arg1:Object):Boolean{
            if (((_arg1.clip) && (_arg1.clip._mochiad))){
                _arg1 = _arg1.clip;
            };
            if (_arg1.origFrameRate != undefined){
                _arg1.stage.frameRate = _arg1.origFrameRate;
            };
            if (!_arg1._mochiad){
                return (false);
            };
            if (_arg1._mochiad._containerLCName != undefined){
                _arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "notify", {id:"unload"});
            };
            if (_arg1._mochiad.onUnload){
                _arg1._mochiad.onUnload();
            };
            delete _arg1._mochiad_loaded;
            delete _arg1._mochiad;
            return (true);
        }
        public static function showInterLevelAd(_arg1:Object):void{
            var clip:* = null;
            var mc:* = null;
            var chk:* = null;
            var options:* = _arg1;
            var DEFAULTS:* = {
                ad_timeout:2000,
                fadeout_time:250,
                regpt:"o",
                method:"showTimedAd",
                ad_started:function ():void{
                    if ((this.clip is MovieClip)){
                        this.clip.stop();
                    } else {
                        throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip.  If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
                    };
                },
                ad_finished:function ():void{
                    if ((this.clip is MovieClip)){
                        this.clip.play();
                    } else {
                        throw (new Error("MochiAd.showInterLevelAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip.  If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
                    };
                },
                ad_loaded:function (_arg1:Number, _arg2:Number):void{
                },
                ad_failed:function ():void{
                    trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
                },
                ad_skipped:function ():void{
                }
            };
            options = MochiAd._parseOptions(options, DEFAULTS);
            clip = options.clip;
            var ad_msec:* = 11000;
            var ad_timeout:* = options.ad_timeout;
            delete options.ad_timeout;
            var fadeout_time:* = options.fadeout_time;
            delete options.fadeout_time;
            if (!MochiAd.load(options)){
                options.ad_failed();
                options.ad_finished();
                return;
            };
            options.ad_started();
            mc = clip._mochiad;
            mc["onUnload"] = function ():void{
                MochiAd._cleanup(mc);
                options.ad_finished();
            };
            var wh:* = MochiAd._getRes(options, clip);
            var w:* = wh[0];
            var h:* = wh[1];
            mc.x = (w * 0.5);
            mc.y = (h * 0.5);
            chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
            chk.ad_msec = ad_msec;
            chk.ad_timeout = ad_timeout;
            chk.started = getTimer();
            chk.showing = false;
            chk.fadeout_time = fadeout_time;
            chk.fadeFunction = function ():void{
                if (!this.parent){
                    delete this.onEnterFrame;
                    delete this.fadeFunction;
                    return;
                };
                var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
                if (_local1 > 0){
                    this.parent.alpha = (_local1 * 0.01);
                } else {
                    MochiAd.unload(clip);
                    delete this["onEnterFrame"];
                };
            };
            mc.unloadAd = function ():void{
                MochiAd.unload(clip);
            };
            mc.adLoaded = options.ad_loaded;
            mc.adSkipped = options.ad_skipped;
            mc.adjustProgress = function (_arg1:Number):void{
                var _local2:Object = mc._mochiad_wait;
                _local2.server_control = true;
                _local2.showing = true;
                _local2.started = getTimer();
                _local2.ad_msec = (_arg1 - 250);
            };
            mc.rpc = function (_arg1:Number, _arg2:Object):void{
                MochiAd.rpc(clip, _arg1, _arg2);
            };
            chk["onEnterFrame"] = function ():void{
                var _local4:Number;
                if (!this.parent){
                    delete this.onEnterFrame;
                    delete this.fadeFunction;
                    return;
                };
                var _local1:Object = this.parent._mochiad_ctr;
                var _local2:Number = (getTimer() - this.started);
                var _local3:Boolean;
                if (!chk.showing){
                    _local4 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
                    if (_local4 > 0){
                        chk.showing = true;
                        chk.started = getTimer();
                        MochiAd.adShowing(clip);
                    } else {
                        if (_local2 > chk.ad_timeout){
                            options.ad_failed();
                            _local3 = true;
                        };
                    };
                };
                if (_local2 > chk.ad_msec){
                    _local3 = true;
                };
                if (_local3){
                    if (this.server_control){
                        delete this.onEnterFrame;
                    } else {
                        this.fadeout_start = getTimer();
                        this.onEnterFrame = this.fadeFunction;
                    };
                };
            };
            doOnEnterFrame(chk);
        }
        public static function _parseOptions(_arg1:Object, _arg2:Object):Object{
            var _local4:String;
            var _local5:Array;
            var _local6:Number;
            var _local7:Array;
            var _local3:Object = {};
            for (_local4 in _arg2) {
                _local3[_local4] = _arg2[_local4];
            };
            if (_arg1){
                for (_local4 in _arg1) {
                    _local3[_local4] = _arg1[_local4];
                };
            };
            if (_local3.clip == undefined){
                throw (new Error("MochiAd is missing the 'clip' parameter.  This should be a MovieClip, Sprite or an instance of a class that extends MovieClip or Sprite."));
            };
            _arg1 = _local3.clip.loaderInfo.parameters.mochiad_options;
            if (_arg1){
                _local5 = _arg1.split("&");
                _local6 = 0;
                while (_local6 < _local5.length) {
                    _local7 = _local5[_local6].split("=");
                    _local3[unescape(_local7[0])] = unescape(_local7[1]);
                    _local6++;
                };
            };
            if (_local3.id == "test"){
                trace("[MochiAd] WARNING: Using the MochiAds test identifier, make sure to use the code from your dashboard, not this example!");
            };
            return (_local3);
        }
        public static function _cleanup(_arg1:Object):void{
            var k:* = null;
            var lc:* = null;
            var f:* = null;
            var mc:* = _arg1;
            if (("lc" in mc)){
                lc = mc.lc;
                f = function ():void{
                    try {
                        lc.client = null;
                        lc.close();
                    } catch(e:Error) {
                    };
                };
                setTimeout(f, 0);
            };
            var idx:* = DisplayObjectContainer(mc).numChildren;
            while (idx > 0) {
                idx = (idx - 1);
                DisplayObjectContainer(mc).removeChildAt(idx);
            };
            for (k in mc) {
                delete mc[k];
            };
        }
        public static function load(_arg1:Object):MovieClip{
            var clip:* = null;
            var k:* = null;
            var server:* = null;
            var hostname:* = null;
            var lc:* = null;
            var name:* = null;
            var loader:* = null;
            var g:* = null;
            var req:* = null;
            var v:* = null;
            var options:* = _arg1;
            var DEFAULTS:* = {
                server:"http://x.mochiads.com/srv/1/",
                method:"load",
                depth:10333,
                id:"_UNKNOWN_"
            };
            options = MochiAd._parseOptions(options, DEFAULTS);
            options.swfv = 9;
            options.mav = MochiAd.getVersion();
            clip = options.clip;
            if (!(clip is DisplayObject)){
                trace("Warning: Object passed as container clip not a descendant of the DisplayObject type");
                return (null);
            };
            if (MovieClip(clip).stage == null){
                trace("Warning: Container clip for ad is not attached to the stage");
                return (null);
            };
            if (!MochiAd._isNetworkAvailable()){
                return (null);
            };
            try {
                if (clip._mochiad_loaded){
                    return (null);
                };
            } catch(e:Error) {
                throw (new Error("MochiAd requires a clip that is an instance of a dynamic class.  If your class extends Sprite or MovieClip, you must make it dynamic."));
            };
            var depth:* = options.depth;
            delete options.depth;
            var mc:* = createEmptyMovieClip(clip, "_mochiad", depth);
            var wh:* = MochiAd._getRes(options, clip);
            options.res = ((wh[0] + "x") + wh[1]);
            options.server = (options.server + options.id);
            delete options.id;
            clip._mochiad_loaded = true;
            if (clip.loaderInfo.loaderURL.indexOf("http") == 0){
                options.as3_swf = clip.loaderInfo.loaderURL;
            } else {
                trace("[MochiAd] NOTE: Security Sandbox Violation errors below are normal");
            };
            var lv:* = new URLVariables();
            for (k in options) {
                v = options[k];
                if (!(v is Function)){
                    lv[k] = v;
                };
            };
            server = lv.server;
            delete lv.server;
            hostname = _allowDomains(server);
            lc = new LocalConnection();
            lc.client = mc;
            name = ["", Math.floor(new Date().getTime()), Math.floor((Math.random() * 999999))].join("_");
            lc.allowDomain("*", "localhost");
            lc.allowInsecureDomain("*", "localhost");
            lc.connect(name);
            mc.lc = lc;
            mc.lcName = name;
            lv.lc = name;
            lv.st = getTimer();
            loader = new Loader();
            g = function (_arg1:Object):void{
                _arg1.target.removeEventListener(_arg1.type, arguments.callee);
                MochiAd.unload(clip);
            };
            loader.contentLoaderInfo.addEventListener(Event.UNLOAD, g);
            req = new URLRequest(((server + ".swf?cacheBust=") + new Date().getTime()));
            req.contentType = "application/x-www-form-urlencoded";
            req.method = URLRequestMethod.POST;
            req.data = lv;
            loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (_arg1:IOErrorEvent):void{
                trace("[MochiAds] Blocked URL");
            });
            if (!options.skip){
                loader.load(req);
            };
            mc.addChild(loader);
            mc._mochiad_ctr = loader;
            return (mc);
        }
        public static function runMethod(_arg1:Object, _arg2:String, _arg3:Array):Object{
            var _local4:Array = _arg2.split(".");
            var _local5:Number = 0;
            while (_local5 < (_local4.length - 1)) {
                if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
                    return (undefined);
                };
                _arg1 = _arg1[_local4[_local5]];
                _local5++;
            };
            if (typeof(_arg1[_local4[_local5]]) == "function"){
                return (_arg1[_local4[_local5]].apply(_arg1, _arg3));
            };
            return (undefined);
        }
        public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number):MovieClip{
            var _local4:MovieClip = new MovieClip();
            if (((false) && (_arg3))){
                _arg1.addChildAt(_local4, _arg3);
            } else {
                _arg1.addChild(_local4);
            };
            _arg1[_arg2] = _local4;
            _local4["_name"] = _arg2;
            return (_local4);
        }
        public static function _getRes(_arg1:Object, _arg2:Object):Array{
            var _local6:Array;
            var _local3:Object = _arg2.getBounds(_arg2.root);
            var _local4:Number = 0;
            var _local5:Number = 0;
            if (typeof(_arg1.res) != "undefined"){
                _local6 = _arg1.res.split("x");
                _local4 = parseFloat(_local6[0]);
                _local5 = parseFloat(_local6[1]);
            } else {
                _local4 = (_local3.xMax - _local3.xMin);
                _local5 = (_local3.yMax - _local3.yMin);
            };
            if ((((_local4 == 0)) || ((_local5 == 0)))){
                _local4 = _arg2.stage.stageWidth;
                _local5 = _arg2.stage.stageHeight;
            };
            return ([_local4, _local5]);
        }
        public static function adShowing(_arg1:Object):void{
            _arg1.origFrameRate = _arg1.stage.frameRate;
            _arg1.stage.frameRate = 30;
        }
        public static function getValue(_arg1:Object, _arg2:String):Object{
            var _local3:Array = _arg2.split(".");
            var _local4:Number = 0;
            while (_local4 < (_local3.length - 1)) {
                if ((((_arg1[_local3[_local4]] == undefined)) || ((_arg1[_local3[_local4]] == null)))){
                    return (undefined);
                };
                _arg1 = _arg1[_local3[_local4]];
                _local4++;
            };
            return (_arg1[_local3[_local4]]);
        }
        public static function rpc(_arg1:Object, _arg2:Number, _arg3:Object):void{
            var _local4:Object;
            var _local5:Object;
            switch (_arg3.id){
                case "setValue":
                    MochiAd.setValue(_arg1, _arg3.objectName, _arg3.value);
                    break;
                case "getValue":
                    _local4 = MochiAd.getValue(_arg1, _arg3.objectName);
                    _arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local4);
                    break;
                case "runMethod":
                    _local5 = MochiAd.runMethod(_arg1, _arg3.method, _arg3.args);
                    _arg1._mochiad.lc.send(_arg1._mochiad._containerLCName, "rpcResult", _arg2, _local5);
                    break;
                default:
                    trace(("[mochiads rpc] unknown rpc id: " + _arg3.id));
            };
        }
        public static function setValue(_arg1:Object, _arg2:String, _arg3:Object):void{
            var _local4:Array = _arg2.split(".");
            var _local5:Number = 0;
            while (_local5 < (_local4.length - 1)) {
                if ((((_arg1[_local4[_local5]] == undefined)) || ((_arg1[_local4[_local5]] == null)))){
                    return;
                };
                _arg1 = _arg1[_local4[_local5]];
                _local5++;
            };
            _arg1[_local4[_local5]] = _arg3;
        }
        public static function showPreGameAd(_arg1:Object):void{
            var clip:* = null;
            var mc:* = null;
            var chk:* = null;
            var complete:* = false;
            var unloaded:* = false;
            var sendHostProgress:* = false;
            var fn:* = null;
            var r:* = null;
            var options:* = _arg1;
            var DEFAULTS:* = {
                ad_timeout:3000,
                fadeout_time:250,
                regpt:"o",
                method:"showPreloaderAd",
                color:0xFF8A00,
                background:16777161,
                outline:13994812,
                no_progress_bar:false,
                ad_started:function ():void{
                    if ((this.clip is MovieClip)){
                        this.clip.stop();
                    } else {
                        throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip.  If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
                    };
                },
                ad_finished:function ():void{
                    if ((this.clip is MovieClip)){
                        this.clip.play();
                    } else {
                        throw (new Error("MochiAd.showPreGameAd requires a clip that is a MovieClip or is an instance of a class that extends MovieClip.  If your clip is a Sprite, then you must provide custom ad_started and ad_finished handlers."));
                    };
                },
                ad_loaded:function (_arg1:Number, _arg2:Number):void{
                },
                ad_failed:function ():void{
                    trace("[MochiAd] Couldn't load an ad, make sure your game's local security sandbox is configured for Access Network Only and that you are not using ad blocking software");
                },
                ad_skipped:function ():void{
                },
                ad_progress:function (_arg1:Number):void{
                },
                progress_override:function (_arg1:Object):Number{
                    return (NaN);
                },
                bar_offset:0
            };
            options = MochiAd._parseOptions(options, DEFAULTS);
            if ("c862232051e0a94e1c3609b3916ddb17".substr(0) == "dfeada81ac97cde83665f81c12da7def"){
                options.ad_started();
                fn = function ():void{
                    options.ad_finished();
                };
                setTimeout(fn, 100);
                return;
            };
            clip = options.clip;
            var ad_msec:* = 11000;
            var ad_timeout:* = options.ad_timeout;
            if (options.skip){
                ad_timeout = 0;
            };
            delete options.ad_timeout;
            var fadeout_time:* = options.fadeout_time;
            delete options.fadeout_time;
            if (!MochiAd.load(options)){
                options.ad_failed();
                options.ad_finished();
                return;
            };
            options.ad_started();
            mc = clip._mochiad;
            mc["onUnload"] = function ():void{
                MochiAd._cleanup(mc);
                var fn:* = function ():void{
                    options.ad_finished();
                };
                setTimeout(fn, 100);
            };
            var wh:* = MochiAd._getRes(options, clip);
            var w:* = wh[0];
            var h:* = wh[1];
            mc.x = (w * 0.5);
            mc.y = (h * 0.5);
            chk = createEmptyMovieClip(mc, "_mochiad_wait", 3);
            chk.x = (w * -0.5);
            chk.y = (h * -0.5);
            var bar:* = createEmptyMovieClip(chk, "_mochiad_bar", 4);
            if (options.no_progress_bar){
                bar.visible = false;
                delete options.no_progress_bar;
            } else {
                bar.x = (10 + options.bar_offset);
                bar.y = (h - 20);
            };
            var bar_w:* = ((w - bar.x) - 10);
            var bar_color:* = options.color;
            delete options.color;
            var bar_background:* = options.background;
            delete options.background;
            var bar_outline:* = options.outline;
            delete options.outline;
            var backing_mc:* = createEmptyMovieClip(bar, "_outline", 1);
            var backing:* = backing_mc.graphics;
            backing.beginFill(bar_background);
            backing.moveTo(0, 0);
            backing.lineTo(bar_w, 0);
            backing.lineTo(bar_w, 10);
            backing.lineTo(0, 10);
            backing.lineTo(0, 0);
            backing.endFill();
            var inside_mc:* = createEmptyMovieClip(bar, "_inside", 2);
            var inside:* = inside_mc.graphics;
            inside.beginFill(bar_color);
            inside.moveTo(0, 0);
            inside.lineTo(bar_w, 0);
            inside.lineTo(bar_w, 10);
            inside.lineTo(0, 10);
            inside.lineTo(0, 0);
            inside.endFill();
            inside_mc.scaleX = 0;
            var outline_mc:* = createEmptyMovieClip(bar, "_outline", 3);
            var outline:* = outline_mc.graphics;
            outline.lineStyle(0, bar_outline, 100);
            outline.moveTo(0, 0);
            outline.lineTo(bar_w, 0);
            outline.lineTo(bar_w, 10);
            outline.lineTo(0, 10);
            outline.lineTo(0, 0);
            chk.ad_msec = ad_msec;
            chk.ad_timeout = ad_timeout;
            chk.started = getTimer();
            chk.showing = false;
            chk.last_pcnt = 0;
            chk.fadeout_time = fadeout_time;
            chk.fadeFunction = function ():void{
                var _local1:Number = (100 * (1 - ((getTimer() - this.fadeout_start) / this.fadeout_time)));
                if (_local1 > 0){
                    this.parent.alpha = (_local1 * 0.01);
                } else {
                    MochiAd.unload(clip);
                    delete this["onEnterFrame"];
                };
            };
            complete = false;
            unloaded = false;
            var progress:* = Math.min(1, options.progress_override(clip));
            var f:* = function (_arg1:Event):void{
                _arg1.target.removeEventListener(_arg1.type, arguments.callee);
                complete = true;
                if (unloaded){
                    MochiAd.unload(clip);
                };
            };
            if (!isNaN(progress)){
                complete = (progress == 1);
            } else {
                if (clip.loaderInfo.bytesLoaded == clip.loaderInfo.bytesTotal){
                    complete = true;
                } else {
                    if ((clip.root is MovieClip)){
                        r = (clip.root as MovieClip);
                        if (r.framesLoaded >= r.totalFrames){
                            complete = true;
                        } else {
                            clip.loaderInfo.addEventListener(Event.COMPLETE, f);
                        };
                    } else {
                        clip.loaderInfo.addEventListener(Event.COMPLETE, f);
                    };
                };
            };
            mc.unloadAd = function ():void{
                unloaded = true;
                if (complete){
                    MochiAd.unload(clip);
                };
            };
            mc.adLoaded = options.ad_loaded;
            mc.adSkipped = options.ad_skipped;
            mc.adjustProgress = function (_arg1:Number):void{
                var _local2:Object = mc._mochiad_wait;
                _local2.server_control = true;
                _local2.showing = true;
                _local2.started = getTimer();
                _local2.ad_msec = _arg1;
            };
            mc.rpc = function (_arg1:Number, _arg2:Object):void{
                MochiAd.rpc(clip, _arg1, _arg2);
            };
            mc.rpcTestFn = function (_arg1:String):Object{
                trace(("[MOCHIAD rpcTestFn] " + _arg1));
                return (_arg1);
            };
            mc.regContLC = function (_arg1:String):void{
                mc._containerLCName = _arg1;
            };
            sendHostProgress = false;
            mc.sendHostLoadProgress = function (_arg1:String):void{
                sendHostProgress = true;
            };
            chk["onEnterFrame"] = function ():void{
                var _local12:Number;
                if (((!(this.parent)) || (!(this.parent.parent)))){
                    delete this["onEnterFrame"];
                    return;
                };
                var _local1:Object = this.parent.parent.root;
                var _local2:Object = this.parent._mochiad_ctr;
                var _local3:Number = (getTimer() - this.started);
                var _local4:Boolean;
                var _local5:Number = _local1.loaderInfo.bytesTotal;
                var _local6:Number = _local1.loaderInfo.bytesLoaded;
                var _local7:Number = Math.min(1, options.progress_override(_local1));
                if (_local7 == 1){
                    complete = true;
                };
                if (complete){
                    _local6 = Math.max(1, _local6);
                    _local5 = _local6;
                };
                var _local8:Number = ((100 * _local6) / _local5);
                if (!isNaN(_local7)){
                    _local8 = (100 * _local7);
                };
                var _local9:Number = ((100 * _local3) / chk.ad_msec);
                var _local10:Object = this._mochiad_bar._inside;
                var _local11:Number = Math.min(100, Math.min(((_local8) || (0)), _local9));
                _local11 = Math.max(this.last_pcnt, _local11);
                this.last_pcnt = _local11;
                _local10.scaleX = (_local11 * 0.01);
                options.ad_progress(_local11);
                if (sendHostProgress){
                    clip._mochiad.lc.send(clip._mochiad._containerLCName, "notify", {
                        id:"hostLoadPcnt",
                        pcnt:_local8
                    });
                    if (_local8 >= 100){
                        sendHostProgress = false;
                    };
                };
                if (!chk.showing){
                    _local12 = this.parent._mochiad_ctr.contentLoaderInfo.bytesTotal;
                    if (_local12 > 0){
                        chk.showing = true;
                        chk.started = getTimer();
                        MochiAd.adShowing(clip);
                    } else {
                        if ((((_local3 > chk.ad_timeout)) && ((_local8 == 100)))){
                            options.ad_failed();
                            _local4 = true;
                        };
                    };
                };
                if (_local3 > chk.ad_msec){
                    _local4 = true;
                };
                if (((complete) && (_local4))){
                    if (unloaded){
                        MochiAd.unload(_local1);
                    } else {
                        if (this.server_control){
                            delete this.onEnterFrame;
                        } else {
                            this.fadeout_start = getTimer();
                            this.onEnterFrame = chk.fadeFunction;
                        };
                    };
                };
            };
            doOnEnterFrame(chk);
        }
        public static function showPreloaderAd(_arg1:Object):void{
            trace("[MochiAd] DEPRECATED: showPreloaderAd was renamed to showPreGameAd in 2.0");
            MochiAd.showPreGameAd(_arg1);
        }
        public static function showTimedAd(_arg1:Object):void{
            trace("[MochiAd] DEPRECATED: showTimedAd was renamed to showInterLevelAd in 2.0");
            MochiAd.showInterLevelAd(_arg1);
        }
        public static function doOnEnterFrame(_arg1:MovieClip):void{
            var mc:* = _arg1;
            var f:* = function (_arg1:Object):void{
                if (((("onEnterFrame" in mc)) && (mc.onEnterFrame))){
                    mc.onEnterFrame();
                } else {
                    _arg1.target.removeEventListener(_arg1.type, arguments.callee);
                };
            };
            mc.addEventListener(Event.ENTER_FRAME, f);
        }

    }
}//package mochicrypt.as3 
